/*
 * joystick.c
 *
 *  Created on: 23-10-2012
 *      Author: Skeith
 */

#include "joystick.h"

void JoyInit(void)
{
	JoySetPinsel();
	IODIR &= JOY_DIR;
}

void JoySetPinsel(void)
{
	tU32 val = 0;
	tU32 maskedVal1;

	maskedVal1 = PINSEL0 & ~JOY_PINSEL_MASK;

	PINSEL0 = maskedVal1 | val;

}

tBool JoyIsUp(void)
{
	tBool ret = FALSE;

	if((IOPIN & JOY_UP) == 0)
	{
		ret = TRUE;
	}

	return ret;
}

tBool JoyIsDown(void)
{
	tBool ret = FALSE;

	if((IOPIN & JOY_DOWN) == 0)
	{
		ret = TRUE;
	}

	return ret;

}

tBool JoyIsLeft(void)
{
	tBool ret = FALSE;

	if((IOPIN & JOY_LEFT) == 0)
	{
		ret = TRUE;
	}

	return ret;
}

tBool JoyIsRight(void)
{
	tBool ret = FALSE;

	if((IOPIN & JOY_RIGHT) == 0)
	{
		ret = TRUE;
	}

	return ret;
}


